<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	request.setAttribute("path", path);//只是为了让el表达式更短一些
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<base href="<%=basePath%>">

<title>作业</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="expires" content="0">
<meta name="keywords" content="keyword1,keyword2,keyword3">
<meta name="description" content="This is my page">
<link rel="icon" href="favicon.ico">

<!-- Bootstrap core CSS -->
<link href="${path}/res/css/bootstrap(2).min.css" rel="stylesheet">
<!-- Bootstrap theme -->
<link href="${path}/res/css/bootstrap-theme.min.css" rel="stylesheet">

<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
      <script src="${path}/res/js/html5shiv.min.js"></script>
      <script src="${path}/res/js/respond.min.js"></script>
    <![endif]-->
</head>

<body class="container" ng-app="myapp">
	<jsp:include page="/header.jsp"></jsp:include>
	<!-- =======================header=========================== -->


	<div class="container">
		<div class="row clearfix">
			<div class="col-md-12 column">
				<ul class="nav nav-tabs" role="tablist">
					<li role="presentation" class="active"><a href="#undone_task"
						role="tab" data-toggle="tab">未完成</a></li>
					<li role="presentation"><a href="#done_task" role="tab"
						data-toggle="tab">已完成</a></li>
					<li role="presentation"><a href="#expired_task" role="tab"
						data-toggle="tab">已过期</a></li>
				</ul>
				<div class="tab-content" ng-controller='TaskController'>
					<div class="tab-pane active" id="undone_task" role="tabpanel">
						<!-- 这是未完成的作业 -->
						<div class="panel-group" role="tablist">
							<div class="panel panel-default">
								<div class="panel-heading panel-title"
									id="collapseListGroupHeading1">
									<div class="row">
										<div class="col-sm-1 col-xs-1 text-center">#</div>
										<div class="col-sm-2 col-xs-2 text-center">作业名称</div>
										<div class="col-sm-2 col-xs-2 text-center">课程</div>
										<div class="col-sm-2 col-xs-2 text-center">截止时间</div>
										<div class="col-sm-2 col-xs-2 text-center">布置时间</div>
										<div class="col-sm-2 col-xs-2 text-center">附件</div>
										<div class="col-sm-1 col-xs-1 text-center">操作</div>
									</div>
								</div>

								<div class="panel-collapse" id="task_panel" role="tabpanel"
									aria-labelledby="collapseListGroupHeading1"
									aria-expanded="true">
									<ul class="list-group">
										<li class="list-group-item" ng-repeat="row in undone_tasks"
											ng-mouseover="mousein($index)">
											<div class="row" data-toggle="tooltip" data-placement="left"
												title="{{row.type}}">
												<div class="col-sm-1 col-xs-1 text-center" ng-bind="$index"></div>
												<div class="col-sm-2 col-xs-2 text-center"
													ng-bind="row.title" data-toggle="collapse"
													data-target="#demo{{$index}}" style="cursor: pointer;"></div>
												<div class="col-sm-2 col-xs-2 text-center"
													ng-bind="row.course"></div>
												<div class="col-sm-2 col-xs-2 text-center"
													ng-bind="row.deadline"></div>
												<div class="col-sm-2 col-xs-2 text-center"
													ng-bind="row.time"></div>
												<!-- 没有附件的情况 -->
												<div class="col-sm-2 col-xs-2 text-center"
													ng-if="row.attachID == -1" ng-bind="row.attach"></div>
												<!-- 有附件的情况 -->
												<div class="col-sm-2 col-xs-2 text-center"
													ng-if="row.attachID != -1">
													<a href="javascript:void(0)" ng-click="download($index,1)"
														data-toggle="tooltip" data-placement="left" title="下载">
														<span class="glyphicon glyphicon-link">&nbsp;{{row.attach}}</span>
													</a>
												</div>
												<div class="col-sm-1 col-xs-1 text-center"
													ng-show='$index == selectedRow'>

													<a href="javascript:void(0);" ng-click="submit($index,1)"
														data-toggle="tooltip" data-placement="left" title="提交作业">
														<span class="glyphicon glyphicon-pencil"></span>
													</a>
												</div>
											</div>
											<div id="demo{{$index}}" class="collapse"
												ng-bind="row.content"></div>
										</li>
									</ul>

								</div>
							</div>
						</div>
					</div>
					<div class="tab-pane" id="done_task">
						<!-- 这是已完成的作业 -->
						<div class="panel-group" role="tablist">
							<div class="panel panel-default">
								<div class="panel-heading panel-title"
									id="collapseListGroupHeading1">
									<div class="row">
										<div class="col-sm-1 col-xs-1 text-center">#</div>
										<div class="col-sm-2 col-xs-2 text-center">作业名称</div>
										<div class="col-sm-2 col-xs-2 text-center">课程</div>
										<div class="col-sm-2 col-xs-2 text-center">截止时间</div>
										<div class="col-sm-2 col-xs-2 text-center">布置时间</div>
										<div class="col-sm-2 col-xs-2 text-center">附件</div>
										<div class="col-sm-1 col-xs-1 text-center">操作</div>
									</div>
								</div>

								<div class="panel-collapse" id="task_panel" role="tabpanel"
									aria-labelledby="collapseListGroupHeading1"
									aria-expanded="true">
									<ul class="list-group">
										<li class="list-group-item" ng-repeat="row in done_tasks"
											ng-mouseover="mousein($index)">
											<div class="row" data-toggle="tooltip" data-placement="left"
												title="{{row.type}}">
												<div class="col-sm-1 col-xs-1 text-center" ng-bind="$index"></div>
												<div class="col-sm-2 col-xs-2 text-center"
													ng-bind="row.title" data-toggle="collapse"
													data-target="#demo{{$index}}" style="cursor: pointer;"></div>
												<div class="col-sm-2 col-xs-2 text-center"
													ng-bind="row.course"></div>
												<div class="col-sm-2 col-xs-2 text-center"
													ng-bind="row.deadline"></div>
												<div class="col-sm-2 col-xs-2 text-center"
													ng-bind="row.time"></div>
												<!-- 没有附件的情况 -->
												<div class="col-sm-2 col-xs-2 text-center"
													ng-if="row.attachID == -1" ng-bind="row.attach"></div>
												<!-- 有附件的情况 -->
												<div class="col-sm-2 col-xs-2 text-center"
													ng-if="row.attachID != -1">
													<a href="javascript:void(0)" ng-click="download($index,2)"
														data-toggle="tooltip" data-placement="left" title="下载">
														<span class="glyphicon glyphicon-link">&nbsp;{{row.attach}}</span>
													</a>
												</div>
												<div class="col-sm-1 col-xs-1 text-center"
													ng-show='$index == selectedRow'>

													<a href="javascript:void(0);" ng-click="submit($index,2)"
														data-toggle="tooltip" data-placement="left" title="修改作业">
														<span class="glyphicon glyphicon-edit"></span>
													</a> <a href="javascript:void(0);" ng-click="preview($index,2)"
														data-toggle="tooltip" data-placement="left"
														title="查看上次提交的作业"> <span
														class="glyphicon glyphicon-eye-open"></span>
													</a>
												</div>
											</div>
											<div id="demo{{$index}}" class="collapse"
												ng-bind="row.content"></div>
										</li>
									</ul>

								</div>
							</div>
						</div>
					</div>
					<div class="tab-pane" id="expired_task">
						<!-- 这是已过期的作业 -->
						<div class="panel-group" role="tablist">
							<div class="panel panel-default">
								<div class="panel-heading panel-title"
									id="collapseListGroupHeading1">
									<div class="row">
										<div class="col-sm-1 col-xs-1 text-center">#</div>
										<div class="col-sm-2 col-xs-2 text-center">作业名称</div>
										<div class="col-sm-2 col-xs-2 text-center">课程</div>
										<div class="col-sm-2 col-xs-2 text-center">截止时间</div>
										<div class="col-sm-2 col-xs-2 text-center">布置时间</div>
										<div class="col-sm-2 col-xs-2 text-center">附件</div>
										<div class="col-sm-1 col-xs-1 text-center">操作</div>
									</div>
								</div>

								<div class="panel-collapse" id="task_panel" role="tabpanel"
									aria-labelledby="collapseListGroupHeading1"
									aria-expanded="true">
									<ul class="list-group">
										<li class="list-group-item" ng-repeat="row in expired_tasks"
											ng-mouseover="mousein($index)">
											<div class="row" data-toggle="tooltip" data-placement="left"
												title="{{row.type}}">
												<div class="col-sm-1 col-xs-1 text-center" ng-bind="$index"></div>
												<div class="col-sm-2 col-xs-2 text-center"
													ng-bind="row.title" data-toggle="collapse"
													data-target="#demo{{$index}}" style="cursor: pointer;"></div>
												<div class="col-sm-2 col-xs-2 text-center"
													ng-bind="row.course"></div>
												<div class="col-sm-2 col-xs-2 text-center"
													ng-bind="row.deadline"></div>
												<div class="col-sm-2 col-xs-2 text-center"
													ng-bind="row.time"></div>
												<!-- 没有附件的情况 -->
												<div class="col-sm-2 col-xs-2 text-center"
													ng-if="row.attachID == -1" ng-bind="row.attach"></div>
												<!-- 有附件的情况 -->
												<div class="col-sm-2 col-xs-2 text-center"
													ng-if="row.attachID != -1">
													<a href="javascript:void(0)" ng-click="download($index,3)"
														data-toggle="tooltip" data-placement="left" title="下载">
														<span class="glyphicon glyphicon-link">&nbsp;{{row.attach}}</span>
													</a>
												</div>
												<div class="col-sm-1 col-xs-1 text-center"
													ng-show='$index == selectedRow'>

													<a href="javascript:void(0);" ng-click="preview($index,3)"
														data-toggle="tooltip" data-placement="left"
														title="查看上次提交的作业"> <span
														class="glyphicon glyphicon-eye-open"></span>
													</a>
												</div>
											</div>
											<div id="demo{{$index}}" class="collapse"
												ng-bind="row.content"></div>
										</li>
									</ul>

								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>

	</div>
	<div class=""></div>
	<!-- 作业查看框 -->
	<div class="modal fade" id="preview_modal_homework" tabindex="-1"
		role="dialog" aria-labelledby="preview_modal_homework_label"
		aria-hidden="true">
		<div class="modal-dialog modal-lg">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal">
						<span aria-hidden="true">&times;</span><span class="sr-only">Close</span>
					</button>
					<h4 class="modal-title" id="preview_modal_homework_label">查看作业</h4>
				</div>
				<div class="modal-body">
					<!-- 查看作业内容区 -->
					<div id="preview_homework">
						<div class="col-sm-offset-2">
							<div class="row form-group">
								<label for="preview_homework_content"
									class="col-sm-2  control-label">答案</label>
								<div class="col-sm-8">
									<p id="preview_homework_content" class="form-control-static"></p>
								</div>
							</div>
							<div class="row form-group">
								<label for="preview_homework_attach"
									class="col-sm-2  control-label">附件</label>
								<div class="col-sm-8">
									<p id="preview_homework_attach" class="form-control-static"></p>
								</div>
							</div>
							<div class="row form-group">
								<label for="preview_homework_note"
									class="col-sm-2  control-label">备注</label>
								<div class="col-sm-8">
									<p id="preview_homework_note" class="form-control-static"></p>
								</div>
							</div>
							<div class="row form-group">
								<label for="preview_homework_pass"
									class="col-sm-2  control-label">是否通过</label>
								<div class="col-sm-8">
									<p id="preview_homework_pass" class="form-control-static"></p>
								</div>
							</div>
							<div class="row form-group">
								<label for="preview_homework_score"
									class="col-sm-2  control-label">分数</label>
								<div class="col-sm-8">
									<p id="preview_homework_score" class="form-control-static"></p>
								</div>
							</div>
							<div class="row form-group">
								<label for="preview_homework_evaluation"
									class="col-sm-2  control-label">教师批注</label>
								<div class="col-sm-8">
									<p id="preview_homework_evaluation" class="form-control-static"></p>
								</div>
							</div>
						</div>
					</div>
				</div>

			</div>
		</div>
	</div>

	<!-- 作业提交框 -->
	<div class="modal fade" id="modal_homework" tabindex="-1" role="dialog"
		aria-labelledby="modal_homework_label" aria-hidden="true">
		<div class="modal-dialog modal-lg">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal">
						<span aria-hidden="true">&times;</span><span class="sr-only">Close</span>
					</button>
					<h4 class="modal-title" id="modal_homework_label">提交作业</h4>
				</div>
				<div class="modal-body">
					<!-- 编辑作业内容区 -->
					<div id="edit_homework">
						<form id="new_homework_form" class="form-horizontal"
							action="homework/upload" method="post" role="form"
							enctype="multipart/form-data" accept-charset="UTF-8">
							<div class="col-sm-offset-2">
								<div class="form-group">
									<label for="homework_content" class="col-sm-2  control-label">作业答案</label>
									<div class="col-sm-8">
										<input class="form-control" id="homework_content"
											maxlength="255" name="homework.content" size="255"
											type="text" placeholder="在此输入答案或选择上传附件">
									</div>
								</div>
								<div class="form-group">
									<label for="homework_file_upload"
										class="col-sm-2  control-label">点击选择上传附件</label>
									<div class="col-sm-8">
										<input id="homework_file_upload" name="file" title="点此上传文件"
											type="file" value="点此选择上传文件">
									</div>
								</div>

								<div class="form-group">
									<label for="homework_file_newFileName"
										class="col-sm-2  control-label">新文件名</label>
									<div class="col-sm-8">
										<input class="form-control" id="homework_file_newFileName"
											placeholder="输入新的文件名，非必须" maxlength="255" name="newFileName"
											size="255" type="text">
									</div>
								</div>

								<div class="col-sm-offset-2 col-sm-8">
									<div class="progress">
										<div class="progress-bar progress-bar-striped"
											aria-valuenow="60" aria-valuemin="0" aria-valuemax="100"
											style="width: 0%">
											<span id="percentValue">0%</span>
										</div>
									</div>
								</div>

								<div class="form-group">
									<div class="col-sm-offset-2 col-sm-8">
										<p id="status" class="form-control-static text-success"
											style="margin-bottom: 20px;"></p>
									</div>
								</div>
								<input type="hidden" id="taskid" name="homework.task.id">
								<input type="hidden" id="homeworkid" name="homework.id">
							</div>
						</form>
					</div>
				</div>
				<div class="modal-footer">
					<input form="new_homework_form" class="btn btn-success btn-lg"
						id="submit_btn" type="submit" value="提交"> <input
						id="reset_btn" form="new_homework_form" class="btn btn-warning"
						type="reset" value="重置">
					<!-- 	 <a id="submit_homework_btn"
						class="btn btn-primary" href="#">提交</a> <a
						id="submit_homework_btn" class="btn btn-primary" href="#">提交</a> -->
				</div>
			</div>
		</div>
	</div>

	<!-- ========================footer========================== -->
	<jsp:include page="/footer.jsp"></jsp:include>
	<!-- Bootstrap core JavaScript
    ================================================== -->
	<!-- Placed at the end of the document so the pages load faster -->
	<script src="${path}/res/js/jquery.min.js"></script>
	<script src="${path}/res/js/bootstrap.min.js"></script>
	<script src="${path}/res/js/jquery.fileupload.js"></script>
	<script src="${path}/res/js/jquery.iframe-transport.js"></script>
	<script src="${path}/res/js/jquery.ui.widget.js"></script>
	<script src="${path}/res/js/jquery.form.js"></script>
	<script src="${path}/res/js/angular.min.js"></script>
	<script src="${path}/res/js/student_task.js"></script>
	<script type="text/javascript">
		var tasks = '${taskJson}';
		var teachs = '${teachJson}';
	</script>
</body>
</html>
